package com.kaibes.imserver.model;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import com.kaibes.imserver.KaibesIMServer;
import com.kaibes.imserver.view.ServerMainView;

public class StartButtonListenerModel implements ActionListener {

	public static boolean flag = false;
	public static JButton jb = null;
	
	public StartButtonListenerModel() {
	}
	
	@Override
	public void actionPerformed(final ActionEvent arg0) {
		jb = (JButton)arg0.getSource();
		if (flag) {
			flag = false;
			KaibesIMServer.mainClientControl.closeServer();
			jb.setText("\u542f\u52a8\u670d\u52a1\u5668");
		} else {
			flag = true;
			ServerMainView.serverPanelView.panel_start.cleanLog();
			ServerMainView.serverPanelView.panel_main.cleanLog();
			ServerMainView.serverPanelView.panel_login.cleanLog();
			ServerMainView.serverPanelView.panel_data.cleanLog();
			ServerMainView.serverPanelView.panel_sets.cleanLog();
//			ServerMainStart.userLoginControl.startServer();
//			ServerMainStart.userMainControl.startServer();
			
			KaibesIMServer.mainClientControl.startServer();
			jb.setText("\u5173\u95ed\u670d\u52a1\u5668");
		}
	}

}
